<template>
  <div>
    <el-card :body-style="{ padding: 0 }" :bordered="false" class="ivu-mt" shadow="never">
      <div class="padding-add">
        <el-form
          ref="tableFrom"
          :label-position="labelPosition"
          :label-width="labelWidth"
          :model="tableFrom"
          inline
          @submit.native.prevent
        >
          <el-form-item label="搜索：" label-for="content">
            <el-input
              v-model="tableFrom.content"
              class="form_content_width"
              placeholder="请输入电话、姓名、编码、邮箱"
            />
          </el-form-item>

          <el-form-item>
            <el-button v-db-click type="primary" @click="userSearchs">查询</el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-card>
    <el-card :bordered="false" class="ivu-mt mt16" shadow="never">
      <el-table
        ref="table"
        v-loading="loading"
        :data="tableList"
        class="mt14"
        highlight-current-row
        no-filtered-userFrom-text="暂无筛选结果"
        no-userFrom-text="暂无数据"
      >
        <el-table-column label="代理ID" width="80">
          <template slot-scope="scope">
            <span>{{ scope.row.leader_id }}</span>
          </template>
        </el-table-column>
        <el-table-column label="代理名称" min-width="120">
          <template slot-scope="scope">
            <span>{{ scope.row.leader_name }}</span>
          </template>
        </el-table-column>
        <el-table-column label="代理电话" min-width="120">
          <template slot-scope="scope">
            <span>{{ scope.row.leader_phone }}</span>
          </template>
        </el-table-column>

        <el-table-column label="被推荐的名称" min-width="120">
          <template slot-scope="scope">
            <span>{{ scope.row.name }}</span>
          </template>
        </el-table-column>
        <el-table-column label="被推荐的手机号" min-width="120">
          <template slot-scope="scope">
            <span>{{ scope.row.phone }}</span>
          </template>
        </el-table-column>
        <el-table-column label="添加时间" min-width="100">
          <template slot-scope="scope">
            <span> {{ scope.row.add_time }}</span>
          </template>
        </el-table-column>
        <!--        <el-table-column fixed="right" label="操作" width="80">-->
        <!--          <template slot-scope="scope">-->
        <!--            <a v-db-click>详情</a>-->
        <!--          </template>-->
        <!--        </el-table-column>-->
      </el-table>
      <div class="acea-row row-right page">
        <pagination
          v-if="total"
          :limit.sync="tableFrom.limit"
          :page.sync="tableFrom.page"
          :total="total"
          @pagination="getList"
        />
      </div>
    </el-card>
  </div>
</template>

<script>
import { mapState } from 'vuex';
import { formatDate } from '@/utils/validate';
import {  recommendListApi } from "@api/agent";

export default {
  name: 'marketing_storeCouponIssue',
  filters: {
    formatDate(time) {
      if (time !== 0) {
        let date = new Date(time * 1000);
        return formatDate(date, 'yyyy-MM-dd hh:mm');
      }
    },
  },
  data() {
    return {
      modals2: false,
      grid: {
        xl: 7,
        lg: 7,
        md: 12,
        sm: 24,
        xs: 24,
      },
      loading: false,

      tableFrom: {
        content: '',
        page: 1,
        limit: 20,
      },

      tableList: [],
      total: 0
    };
  },
  activated() {
    this.getList();
  },
  created() {
    this.getList();
  },
  computed: {
    ...mapState('media', ['isMobile']),
    labelWidth() {
      return this.isMobile ? undefined : '90px';
    },
    labelPosition() {
      return this.isMobile ? 'top' : 'right';
    },
  },
  methods: {
    // 列表
    getList() {
      this.loading = true;
      recommendListApi(this.tableFrom)
        .then(async (res) => {
          let data = res.data;
          this.tableList = data.list;
          this.total = res.data.count;
          this.loading = false;
        })
        .catch((res) => {
          this.loading = false;
          this.$message.error(res.msg);
        });
    },
    // 表格搜索
    userSearchs() {
      this.tableFrom.page = 1;
      this.getList();
    },
    // 复制
    edit(data) {
      this.$router.push({
        path: this.$routeProStr + `/order/store_coupon_issue/create/${data.id}/1`,
      });
    }
  },
};
</script>

<style lang="stylus" scoped>
.fa {
  color: #0a6aa1;
  display: block;
}

.sheng {
  color: #ff0000;
  display: block;
}

.tabBox_img {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  cursor: pointer;

  img {
    width: 100%;
    height: 100%;
  }
}
</style>
